//
//  CHTSTableViewCell.m
//  CarFile
//
//  Created by 陈浩 on 2017/7/31.
//  Copyright © 2017年 陈浩. All rights reserved.
//

#import "CHTSTableViewCell.h"
#import "CHComplainListModel.h"
@interface CHTSTableViewCell()

@property (nonatomic ,strong) UILabel *titleLabel;
@property (nonatomic ,strong) UILabel *timeLabel;
@property (nonatomic ,strong) UILabel *phoneLabel;

@end
@implementation CHTSTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

+(instancetype)cellForTableView:(UITableView *)tableView{
    static NSString *ID = @"CHTSTableViewCell";
    CHTSTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[CHTSTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    return cell;
    
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self buildUI];
        
    }
    return self;
    
}

-(void)buildUI{
    
    UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 15, UIScreenW/2 -15, 30)];
    titleLabel.numberOfLines = 0;
    titleLabel.textColor =  [UIColor colorWithHexString:@"168bce" alpha:1.0f];
    titleLabel.font = [UIFont systemFontOfSize:14];
    [self addSubview:titleLabel];
    self.titleLabel = titleLabel;
    
    UILabel *timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(UIScreenW /2, 20, UIScreenW /2 -15, 20)];
    timeLabel.textAlignment = NSTextAlignmentRight;
    timeLabel.textColor = [UIColor colorWithHexString:@"666666" alpha:1.0f];
    timeLabel.font = [UIFont systemFontOfSize:12];
    [self addSubview:timeLabel];
    self.timeLabel = timeLabel;
    
    UIImageView *iconImgView = [[UIImageView alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(timeLabel.frame)+5, 30, 30)];
    iconImgView.image = [UIImage imageNamed:@"car_icon"];
    [self addSubview:iconImgView];
    
    
    UILabel *phoneLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(iconImgView.frame) + 10, CGRectGetMaxY(titleLabel.frame), 150, 30)];
    phoneLabel.font = [UIFont systemFontOfSize:13];
    phoneLabel.textColor = [UIColor colorWithHexString:@"666666" alpha:1.0f];
    [self addSubview:phoneLabel];
    self.phoneLabel = phoneLabel;
    
    UILabel *infoLabel = [[UILabel alloc] initWithFrame:CGRectMake(UIScreenW - 80 - 15, CGRectGetMaxY(timeLabel.frame)+10, 80, 25)];
    infoLabel.font = [UIFont systemFontOfSize:13];
    infoLabel.text = @"查看详情";
    infoLabel.layer.cornerRadius = 3;
    infoLabel.layer.masksToBounds = YES;
    infoLabel.textAlignment = NSTextAlignmentCenter;
    infoLabel.textColor = [UIColor whiteColor];
    infoLabel.backgroundColor = [UIColor colorWithHexString:@"168bce" alpha:1.0f];
    [self addSubview:infoLabel];
    
    
}


-(void)setComplainListFrm:(CHComplainListFrame *)complainListFrm{
    _complainListFrm = complainListFrm;
    CHComplainListModel *model = complainListFrm.model;
    self.titleLabel.text = model.company;
    self.timeLabel.text =  model.complainttime;
    self.phoneLabel.text = [model.mobilephone stringByReplacingCharactersInRange:NSMakeRange(3, 4) withString:@"****"];;
    
    
}

@end
